<template>
  <!-- class="app-container" -->
  <div>
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <!-- <el-form-item label="" prop="platform">
        <el-select
          v-model="queryParams.platform"
          placeholder="平台名称"
          clearable
        >
          <el-option
            v-for="dict in dict.type.sys_sample_name"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="" prop="talentLevel">
        <el-select
          v-model="queryParams.talentLevel"
          placeholder="达人层级"
          clearable
        >
          <el-option
            v-for="dict in dict.type.sys_sample_cj"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item> -->
      <el-form-item label="" prop="platformId">
        <el-input v-model="queryParams.platformId" placeholder="请输入平台ID" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="" prop="xhsNickname" label-width="100px">
        <el-select v-model="queryParams.xhsNickname" clearable filterable placeholder="请输入昵称">
          <el-option v-for="(item, i) in xhsNicknameList" :key="i" :label="`${item}`" :value="item">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="" prop="contactPerson">
        <el-input v-model="queryParams.contactPerson" placeholder="跟进媒介" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <!--<el-form-item label="" prop="recommendSituation">
        <el-input
          v-model="queryParams.recommendSituation"
          placeholder="请输入种草情况"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="" prop="reason">
        <el-input
          v-model="queryParams.reason"
          placeholder="请输入理由"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="" prop="homeLink">
        <el-input
          v-model="queryParams.homeLink"
          placeholder="请输入达人主页"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="" prop="fansNumStart">
        <el-input
          style="width: 140px"
          type="number"
          v-model="queryParams.fansNumStart"
          placeholder="最低粉丝量(W)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="" prop="fansNumEnd">
        <el-input
          style="width: 140px"
          type="number"
          v-model="queryParams.fansNumEnd"
          placeholder="最高粉丝量(W)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="" prop="likeNumStart">
        <el-input
          style="width: 140px"
          type="number"
          v-model="queryParams.likeNumStart"
          placeholder="最低赞藏量(W)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="" prop="likeNumEnd">
        <el-input
          style="width: 140px"
          type="number"
          v-model="queryParams.likeNumEnd"
          placeholder="最高赞藏量(W)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="" prop="cooperatePrice">
        <el-input
          v-model="queryParams.cooperatePrice"
          placeholder="请输入合作报价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="" prop="contactWechat">
        <el-input
          v-model="queryParams.contactWechat"
          placeholder="请输入联系方式"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="" prop="talentStatus">
        <!-- <el-input v-model="queryParams.platform" placeholder="请输入平台名称" clearable @keyup.enter.native="handleQuery" /> -->
        <el-select v-model="queryParams.talentStatus" placeholder="状态" clearable>
          <el-option v-for="dict in dict.type.sys_sample_status" :key="dict.value" :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="逻辑删除;0=未删除；1=已删除" prop="isDelete">
        <el-input v-model="queryParams.isDelete" placeholder="请输入逻辑删除;0=未删除；1=已删除" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-dialog :visible.sync="openOrderNumber" append-to-body title="批量分配" width="500px" v-if="openOrderNumber">
      <el-form ref="formApply" :model="formApply">
        <el-form-item label="分配跟进商务(BD)/媒介(PR)" prop="contactPerson">
          <!-- <el-input style="width: 200px" v-model="formApply.contactPerson" placeholder="分配跟进商务(BD)/媒介(PR)" /> -->
          <el-select v-model="formApply.contactPerson" clearable placeholder="目标责任人" filterable>
            <el-option v-for="(val, key) in userList" :key="key" :label="val" :value="val" />
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer" style="margin-top: 50px">
        <el-button type="primary" @click="handlebatchDistributionTalent">确 定</el-button>

        <!-- <el-button @click="cancelApply">取消</el-button> -->
      </div>
    </el-dialog>

    <!-- 添加或修改产品二级信息对话框 :on-change="handleChange"-->
    <el-dialog :visible.sync="openUpload" width="500px" append-to-body v-if="openUpload">
      <el-form label-width="150px">
        <el-form-item label="导入模板下载" prop="file">
          <el-button size="mini" plain icon="el-icon-download" @click="downLoadTemplateFile">批量模板</el-button>
        </el-form-item>
        <el-form-item label="导入文件" prop="file">
          <uploadFile @handleSuccess="getList" :uploadUrl="'/product/sample/importData'" />
        </el-form-item>
      </el-form>
    </el-dialog>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['product:sample:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['product:sample:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['product:sample:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['product:sample:export']">导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" plain size="mini" @click="handleformApply">批量分配</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" plain size="mini" @click="openUpload = true">批量导入</el-button>
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button size="mini" plain icon="el-icon-plus" @click="chatAdd"
          >笔记合作</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button size="mini" plain icon="el-icon-plus" @click="chatlive"
          >直播寄样</el-button
        >
      </el-col>
      <el-col :span="1.5" style="display: none">
        <el-button size="mini" plain icon="el-icon-plus" @click="chatVFU"
          >内部寄样</el-button
        >
      </el-col> -->
      <!-- <el-col :span="1.5">
        <el-button
          size="mini"
          plain
          icon="el-icon-plus"
          @click="chatReturn"
          v-hasPermi="['product:sampleApply:returnApply']"
          >发起退货</el-button
        >
      </el-col> -->
      <!-- <el-col :span="1.5">
        <el-button
          size="mini"
          plain
          icon="el-icon-plus"
          @click="chatReturn"
          v-hasPermi="['product:sampleApply:returnApply']"
          >自行寄出</el-button
        >
      </el-col> -->
      <!-- <el-col :span="1.5">
        <el-button
          size="mini"
          plain
          @click="chatReturn"
          v-hasPermi="['product:sampleApply:returnApply']"
          >发起退货</el-button
        >
      </el-col> -->
      <!-- <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAddAll">新增寄样</el-button>
      </el-col> -->
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <!-- 属性面板 -->
    <el-drawer title="达人详情" :before-close="handleClose" :visible.sync="showDetail" direction="rtl"
      custom-class="demo-drawer" ref="drawer" size="65%">
      <Detail :row="row" />
    </el-drawer>
    <!-- <div ref="tableDom"> -->
    <el-table v-loading="loading" :maxHeight="sampleList.length ? tableHeight : 'auto'" :data="sampleList"
      @selection-change="handleSelectionChange" :height="620" :header-cell-style="tableRowClassName">
      <el-table-column type="selection" width="50" align="center" />
      <el-table-column prop="id" label="ID"></el-table-column>
      <el-table-column prop="platform" label="平台名称"></el-table-column>

      <el-table-column width="120" prop="xhsNickname" label="达人昵称">
        <template slot-scope="scope">
          <div style="
              color: rgb(37, 137, 255);
              cursor: pointer;
              text-decoration: underline;
            " @click="handleNickname(scope.row)">
            {{ scope.row.xhsNickname }}
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="platformId" label="达人ID" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="personnelType" label="标签" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column label="粉丝量(W)" align="center" prop="fansNum" />
      <el-table-column prop="talentLevel" label="达人层级"></el-table-column>
      <el-table-column prop="talentIntro" label="达人简介"></el-table-column>
      <el-table-column prop="contactPerson" label="跟进媒介（BD）"></el-table-column>
      <el-table-column prop="talentStatus" label="状态"></el-table-column>
      <el-table-column label="样衣记录" align="center" prop="">
        <template slot-scope="scope">
          <div style="
              color: rgb(37, 137, 255);
              cursor: pointer;
              text-decoration: underline;
            " @click="gotoApply(scope.row)">
            样衣详情
          </div>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleNickname(scope.row)">更多</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog :visible.sync="openInfo" width="90%" append-to-body v-if="openInfo" title="样衣记录">
      <dialogApply :row="row"></dialogApply>
    </el-dialog>
    <!-- <el-table-column label="达人ID" align="center" prop="id" /> -->
    <!-- <el-table-column label="平台名称" align="center" prop="platform" />
      <el-table-column label="达人层级" align="center" prop="talentLevel" />
      <el-table-column
        label="平台ID"
        align="center"
        prop="platformId"
        width="130"
      />
      <el-table-column
        label="昵称"
        align="center"
        prop="xhsNickname"
        width="180"
      />
      <el-table-column
        label="对接人"
        align="center"
        prop="contactPerson"
        width="130"
      /> 
      <el-table-column
        label="种草情况"
        align="center"
        prop="recommendSituation"
      >
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="top" width="300">
            <el-input
              v-model="scope.row.recommendSituation"
              :min-height="192"
              type="textarea"
              :autosize="{ minRows: 2, maxRows: 24 }"
              :style="{ width: '100%' }"
              :disabled="true"
            />
            <div slot="reference">
              <span class="textname">{{ scope.row.recommendSituation }} </span>
            </div>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column label="理由" align="center" prop="reason">
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="top" width="300">
            <el-input
              v-model="scope.row.reason"
              :min-height="192"
              type="textarea"
              :autosize="{ minRows: 2, maxRows: 24 }"
              :style="{ width: '100%' }"
              :disabled="true"
            />
            <div slot="reference">
              <span class="textname">{{ scope.row.reason }} </span>
            </div>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column
        label="人设类型/标签"
        align="center"
        prop="personnelType"
        width="110px"
      />
      <el-table-column label="达人主页" align="center" prop="homeLink">
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="top" width="300">
            <el-input
              v-model="scope.row.homeLink"
              :min-height="192"
              type="textarea"
              :autosize="{ minRows: 2, maxRows: 24 }"
              :style="{ width: '100%' }"
              :disabled="true"
            />
            <div slot="reference">
              <span class="textname">{{ scope.row.homeLink }} </span>
            </div>
          </el-popover>
        </template>
      </el-table-column>
      
      <el-table-column label="赞藏量(W)" align="center" prop="likeNum" />
      <el-table-column label="合作报价" align="center" prop="cooperatePrice">
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="top" width="300">
            <el-input
              v-model="scope.row.cooperatePrice"
              :min-height="192"
              type="textarea"
              :autosize="{ minRows: 2, maxRows: 24 }"
              :style="{ width: '100%' }"
              :disabled="true"
            />
            <div slot="reference">
              <span class="textname">{{ scope.row.cooperatePrice }} </span>
            </div>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column
        label="联系方式"
        align="center"
        prop="contactWechat"
        width="130"
      />
      <el-table-column
        label="联系信息"
        align="center"
        prop="contactWechat"
        width="130"
      >
        <template slot-scope="scope">
          <div
            style="
              color: rgb(37, 137, 255);
              cursor: pointer;
              text-decoration: underline;
            "
            @click="contact(scope.row)"
          >
            收件方式
          </div>
          <el-button size="mini" @click="go(scope.row)">
            收件地址配置
          </el-button>
        </template>
      </el-table-column>
      <el-table-column
        label="支付信息"
        align="center"
        prop="contactWechat"
        width="130"
      >
        <template slot-scope="scope">
          <div
            style="
              color: rgb(37, 137, 255);
              cursor: pointer;
              text-decoration: underline;
            "
            @click="pay(scope.row)"
          >
            支付方式
          </div>
          <el-button size="mini" @click="goto(scope.row)">
            支付信息配置
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="talentStatus" />
      <el-table-column label="备注" align="center" prop="remark" />
      

      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['product:sample:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['product:sample:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
      -->

    <!-- </div> -->

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改样衣申请记录对话框 -->
    <el-dialog title="新增寄样" :visible.sync="openAll" width="80%" append-to-body v-if="openAll">
      <div class="el-dialog-div">
        <el-form ref="form" :model="form" :rules="rules" label-width="100px">
          <el-col :span="7">
            <!-- <el-form-item label="达人信息表ID" prop="sampleTalentInfoId">
              <el-input v-model="form.sampleTalentInfoId" placeholder="达人信息表ID" />
            </el-form-item>
            <el-form-item label="笔记/直播合作ID" prop="sampleTalentCooperateId">
              <el-input v-model="form.sampleTalentCooperateId" placeholder="笔记/直播合作ID" />
            </el-form-item> -->
            <!-- <el-form-item label="模板ID" prop="templateId">
              <el-input v-model="form.templateId" placeholder="模板ID" />
            </el-form-item> -->
            <!-- <el-form-item label="颜色ID" prop="templateSecondryId">
              <el-input v-model="form.templateSecondryId" placeholder="颜色ID" />
            </el-form-item>
            <el-form-item label="尺寸ID" prop="templateSizeId">
              <el-input v-model="form.templateSizeId" placeholder="尺寸ID" />
            </el-form-item>
            <el-form-item label="联系方式ID" prop="contactId">
              <el-input v-model="form.contactId" placeholder="联系方式ID" />
            </el-form-item> -->

            <el-form-item label="合作款式" prop="productNo">
              <!-- <el-input v-model="form.productNo" placeholder="请输入货号" /> -->
              <el-select v-model="form.productNo" clearable filterable remote :remote-method="getDatas" :loading="loading"
                placeholder="请选择合作款式">
                <el-option v-for="item in options" :key="item" :label="item" :value="item">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="颜色属性" prop="colorProperty">
              <!-- <el-input v-model="form.colorProperty" placeholder="请输入颜色属性" :loading="loading"/> -->
              <el-select @focus="onFocus" v-model="form.colorProperty" clearable filterable remote
                :remote-method="getData" placeholder="请选择颜色属性">
                <el-option v-for="item in ColorLike" :key="item" :label="item" :value="item">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="尺寸" prop="size">
              <el-select @focus="onFocus" v-model="form.size" clearable filterable remote :remote-method="getSize"
                placeholder="请选择尺寸">
                <el-option v-for="item in sizeList" :key="item.id" :label="item.size" :value="item.size">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="商品数量" prop="productNum">
              <el-input v-model="form.productNum" placeholder="商品数量" />
              <span style="color: red">当前库存量：</span>
            </el-form-item>
            <el-form-item label="快递公司" prop="expressCompany">
              <!-- <el-input v-model="form.expressCompany" placeholder="快递公司" /> -->
              <el-select v-model="form.expressCompany" placeholder="请选择快递公司" clearable filterable>
                <el-option v-for="dict in dict.type.sys_sample_sf" :key="dict.value" :label="dict.label"
                  :value="dict.label" />
              </el-select>
            </el-form-item>
            <el-form-item label="是否归还" prop="isReturn">
              <el-select v-model="form.isReturn" placeholder="请选择是否归还" clearable filterable>
                <el-option v-for="dict in dict.type.sys_one_zero" :key="dict.value" :label="dict.label"
                  :value="dict.label" />
              </el-select>
            </el-form-item>
            <el-form-item label="所在区域" prop="">
              <el-row>
                <el-select v-model="form.receiverState" placeholder="请选择" @change="selectProvimce" style="width: 100px">
                  <el-option v-for="(item, index) of provincearr" :key="index" :label="item.name"
                    :value="item.name"></el-option>
                </el-select>
                <el-select v-model="form.receiverCity" placeholder="请选择" @change="selectcity" style="width: 100px">
                  <el-option v-for="(item, index) of cityarr" :key="index" :label="item.name"
                    :value="item.name"></el-option>
                </el-select>
                <el-select placeholder="请选择" v-model="form.receiverDistrict" style="width: 110px">
                  <el-option v-for="(item, index) of regionarr" :key="index" :label="item.name"
                    :value="item.name"></el-option>
                </el-select>
              </el-row>
            </el-form-item>
            <el-form-item label="收件人地址" prop="address">
              <el-input v-model="form.address" placeholder="请输入收件人地址" style="width: 300px" />
            </el-form-item>
          </el-col>
          <el-col :span="1">
            <el-form-item></el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="合作方式" prop="talentLevel">
              <el-input v-model="form.talentLevel" placeholder="请输入合作方式" />
            </el-form-item>

            <el-form-item label="平台名称" prop="platform">
              <el-input v-model="form.platform" placeholder="请输入平台名称" />
              <!-- <el-select v-model="form.platform" placeholder="平台名称" clearable>
                <el-option v-for="dict in dict.type.sys_product_qudao" :key="dict.value" :label="dict.label"
                  :value="dict.value" />
              </el-select> -->
            </el-form-item>
            <el-form-item label="达人层级" prop="talentLevel">
              <el-input v-model="form.talentLevel" placeholder="请输入达人层级" />
            </el-form-item>
            <el-form-item label="平台ID" prop="platformId">
              <el-input v-model="form.platformId" placeholder="请输入平台ID" />
            </el-form-item>
            <el-form-item label="昵称" prop="xhsNickname">
              <el-input v-model="form.xhsNickname" placeholder="请输入昵称" />
            </el-form-item>
            <el-form-item label="对接人" prop="contactPerson">
              <el-input v-model="form.contactPerson" placeholder="请输入对接人" />
            </el-form-item>
            <el-form-item label="种草情况" prop="recommendSituation">
              <!-- <el-input v-model="form.recommendSituation" placeholder="请输入种草情况" /> -->
              <el-input v-model="form.recommendSituation" placeholder="种草情况" type="textarea"
                :autosize="{ minRows: 2, maxRows: 12 }" :style="{ width: '100%' }" />
            </el-form-item>
            <el-form-item label="理由" prop="reason">
              <!-- <el-input v-model="form.reason" placeholder="请输入理由" /> -->
              <el-input v-model="form.reason" placeholder="理由" type="textarea" :autosize="{ minRows: 2, maxRows: 12 }"
                :style="{ width: '100%' }" />
            </el-form-item>
          </el-col>
          <el-col :span="1">
            <el-form-item></el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="达人主页" prop="homeLink">
              <!-- <el-input v-model="form.homeLink" placeholder="请输入达人主页" /> -->
              <el-input v-model="form.homeLink" placeholder="请输入达人主页" type="textarea"
                :autosize="{ minRows: 2, maxRows: 12 }" :style="{ width: '100%' }" />
            </el-form-item>
            <el-form-item label="粉丝量(W)" prop="fansNum">
              <el-input v-model="form.fansNum" placeholder="请输入粉丝量" />
            </el-form-item>
            <el-form-item label="赞藏量(W)" prop="likeNum">
              <el-input v-model="form.likeNum" placeholder="请输入赞藏量" />
            </el-form-item>
            <el-form-item label="合作报价" prop="cooperatePrice">
              <!-- <el-input v-model="form.cooperatePrice" placeholder="请输入合作报价" /> -->
              <el-input v-model="form.cooperatePrice" placeholder="请输入合作报价" type="textarea"
                :autosize="{ minRows: 2, maxRows: 12 }" :style="{ width: '100%' }" />
            </el-form-item>
            <el-form-item label="联系方式" prop="contactWechat">
              <el-input v-model="form.contactWechat" placeholder="请输入联系方式" />
            </el-form-item>

            <el-form-item label="状态" prop="talentStatus">
              <!-- <el-input v-model="queryParams.platform" placeholder="请输入平台名称" clearable @keyup.enter.native="handleQuery" /> -->
              <el-select v-model="form.talentStatus" placeholder="状态" clearable>
                <el-option v-for="dict in dict.type.sys_sample_status" :key="dict.value" :label="dict.label"
                  :value="dict.value" />
              </el-select>
            </el-form-item>
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" placeholder="备注" />
            </el-form-item>
          </el-col>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormAll">确 定</el-button>
        <el-button @click="cancelAll">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog :visible.sync="openLabel" append-to-body title="标签管理" width="500px" v-if="openLabel">
      <el-form ref="formLabel" :model="formLabel" label-width="100px" @submit.native.prevent>
        <el-form-item label="标签管理" prop="talentLabel">
          <el-tag style="margin: 2px" :key="tag" v-for="tag in dynamicTags" closable :disable-transitions="false"
            @close="handleClose(tag)">
            {{ tag }}
          </el-tag>
          <el-input class="input-new-tag" v-if="inputVisible" v-model="inputValue" ref="saveTagInput" size="small"
            @keyup.enter.native="handleInputConfirm" @blur="handleInputConfirm">
          </el-input>
          <el-button v-else class="button-new-tag" size="small" @click="showInput">+ 新标签</el-button>
          <!-- <el-input v-model="formLabel.talentLabel" placeholder="标签" /> -->
        </el-form-item>
        <el-form-item label="可选标签" prop="talentLabel">
          <el-tag style="margin: 2px" v-for="dict in TalentLabelList" @click="handleselectLabel(dict)">{{ dict }}</el-tag>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer" style="margin-top: 50px">
        <el-button type="primary" @click="handlesetLabel">确 定</el-button>

        <!-- <el-button @click="cancelApply">取消</el-button> -->
      </div>
    </el-dialog>
    <!-- 添加或修改达人信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="60%" height="80%" append-to-body>
      <div class="el-dialog-div">
        <el-form ref="form" :model="form" :rules="rules" label-width="100px" :inline="true">
          <el-col :span="8">
            <!-- <el-form-item label="平台名称" prop="platform">              
              <el-select
                v-model="form.platform"
                placeholder="平台名称"
                clearable
              >
                <el-option
                  v-for="dict in dict.type.sys_sample_name"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item> -->
            <el-form-item label="达人层级" prop="talentLevel">
              <!-- <el-input v-model="form.talentLevel" placeholder="请输入达人层级" /> -->
              <el-select v-model="form.talentLevel" placeholder="达人层级" clearable>
                <el-option v-for="dict in dict.type.sys_sample_cj" :key="dict.value" :label="dict.label"
                  :value="dict.value" />
              </el-select>
            </el-form-item>
            <el-form-item label="平台ID" prop="platformId">
              <el-input v-model="form.platformId" placeholder="请输入平台ID" />
            </el-form-item>
            <el-form-item label="达人昵称" prop="xhsNickname">
              <el-input v-model="form.xhsNickname" placeholder="请输入达人昵称" />
            </el-form-item>
            <el-form-item label="人设/标签" prop="personnelType">
              <el-button size="mini" plain @click="handleopenLabel">人设/标签</el-button>
            </el-form-item>
            <el-form-item label="图文报价(元)" prop="graphicQuote">
              <el-input v-model="form.graphicQuote" placeholder="图文报价" />
            </el-form-item>
            <el-form-item label="视频报价(元)" prop="videoQuote">
              <el-input v-model="form.videoQuote" placeholder="视频报价" />
            </el-form-item>
            <el-form-item label="直播报价(元)" prop="liveQuote">
              <el-input v-model="form.liveQuote" placeholder="直播报价" />
            </el-form-item>
            <!-- <el-form-item label="对接人" prop="contactPerson">
              <el-input v-model="form.contactPerson" placeholder="请输入对接人" />
            </el-form-item>
            <el-form-item label="种草情况" prop="recommendSituation">
             
              <el-input v-model="form.recommendSituation" placeholder="种草情况" type="textarea"
                :autosize="{ minRows: 2, maxRows: 12 }" :style="{ width: '100%' }" />
            </el-form-item>
            <el-form-item label="理由" prop="reason">
              
              <el-input v-model="form.reason" placeholder="理由" type="textarea" :autosize="{ minRows: 2, maxRows: 12 }"
                :style="{ width: '100%' }" />
            </el-form-item> -->
          </el-col>
          <el-col :span="1">
            <el-form-item></el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="达人主页" prop="homeLink">
              <!-- <el-input v-model="form.homeLink" placeholder="请输入达人主页" /> -->
              <el-input v-model="form.homeLink" placeholder="请输入达人主页" type="textarea"
                :autosize="{ minRows: 2, maxRows: 12 }" :style="{ width: '100%' }" />
              <!-- <el-button type="primary" size="mini" @click="addText"
                >识别</el-button
              > -->
            </el-form-item>
            <el-form-item label="待跟进" prop="isFollow">
              <!-- <el-input v-model="form.isFollow" placeholder="待跟进" /> -->
              <el-select v-model="form.isFollow" placeholder="待跟进" clearable>
                <el-option v-for="dict in isFollowList" :key="dict" :label="dict" :value="dict" />
              </el-select>
            </el-form-item>
            <el-form-item label="粉丝量(W)" prop="fansNum">
              <el-input type="number" v-model="form.fansNum" placeholder="请输入粉丝量" />
            </el-form-item>
            <!-- <el-form-item label="赞藏量(W)" prop="likeNum">
              <el-input type="number" v-model="form.likeNum" placeholder="请输入赞藏量" />
            </el-form-item>
            <el-form-item label="合作报价" prop="cooperatePrice">
              
              <el-input v-model="form.cooperatePrice" placeholder="请输入合作报价" type="textarea"
                :autosize="{ minRows: 2, maxRows: 12 }" :style="{ width: '100%' }" />
            </el-form-item> -->
            <el-form-item label="联系方式" prop="contactWechat" label-width="80px">
              <!-- <el-input v-model="form.contactWechat" placeholder="请输入联系方式" /> -->
              <el-select v-model="form.contactWechat" placeholder="联系方式" clearable>
                <el-option v-for="dict in BiTalentContactsList" :key="dict.id" :label="dict.contactDetails"
                  :value="dict.contactDetails" />
              </el-select>
              <el-button type="primary" size="mini" @click="handleBiTalentContacts">+</el-button>
            </el-form-item>

            <!-- <el-form-item label="状态" prop="talentStatus">
              
              <el-select v-model="form.talentStatus" placeholder="状态" clearable>
                <el-option v-for="dict in dict.type.sys_sample_status" :key="dict.value" :label="dict.label"
                  :value="dict.value" />
              </el-select>
            </el-form-item> -->
            <el-form-item label="达人简介" prop="talentIntro">
              <el-input v-model="form.talentIntro" placeholder="达人简介" />
            </el-form-item>
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" placeholder="备注" />
            </el-form-item>

            <!-- <el-form-item label="逻辑删除;0=未删除；1=已删除" prop="isDelete">
          <el-input v-model="form.isDelete" placeholder="请输入逻辑删除;0=未删除；1=已删除" />
        </el-form-item> -->
          </el-col>
          <el-col :span="1">
            <el-form-item></el-form-item>
          </el-col>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </div>
    </el-dialog>

    <el-dialog :visible.sync="openBiTalentContacts" append-to-body title="联系人信息" width="1500px"
      v-if="openBiTalentContacts" @close="getBiTalentContacts">
      <BiTalentContacts :row="form" />
    </el-dialog>
    <!-- 笔记合作方式 -->
    <el-dialog :visible.sync="Visiblenote" append-to-body title="笔记合作" width="500px" v-if="Visiblenote">
      <el-form ref="fAdd" :model="fAdd" :rules="rules" label-width="100px" :inline="true">
        <el-row v-for="(noticItem, index) in colorProperty" :key="index">
          <el-col>
            <el-form-item label="合作款式" prop="colorProperty">
              <!-- <el-input v-model="noticItem.value" placeholder="请输入颜色属性" /> -->
              <el-select v-model="noticItem.value" clearable filterable remote :remote-method="getData" :loading="loading"
                placeholder="合作款式">
                <el-option v-for="item in productNooptions" :key="item" :label="item" :value="item">
                </el-option>
              </el-select>
            </el-form-item>
            <el-button type="primary" size="mini" @click="addDomain">新增</el-button>
            <el-button type="danger" size="mini" @click.prevent="removeDomain(noticItem)">删除</el-button>
          </el-col>

        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer" style="margin-top: 50px">
        <el-button type="primary" @click="submitNote">确 定</el-button>
        <!-- <el-button @click="canNew">取 消</el-button> -->
      </div>
    </el-dialog>

    <!-- 直播合作方式 -->
    <el-dialog :visible.sync="VisibleLive" append-to-body title="直播合作" width="600px" v-if="VisibleLive">
      <el-form ref="fLive" :model="fLive" :rules="rules" label-width="110px" :inline="true">
        <el-form-item label="请选择收件地址" prop="address">
          <el-select v-model="fLive.id" :automaticDropdown="true">
            <el-option v-for="item in optionsContact" :key="item.id"
              :label="`${item.recipient},${item.phone},${item.receiverState}${item.receiverCity}${item.receiverDistrict}${item.address}`"
              :value="item.id" />
          </el-select>
        </el-form-item>
        <el-form-item label="是否归还" prop="isReturn">
          <!-- <el-input v-model="formVFU.isReturn" placeholder="是否归还" /> -->
          <el-select v-model="fLive.isReturn" placeholder="请选择是否归还" clearable filterable>
            <el-option v-for="dict in dict.type.sys_one_zero" :key="dict.value" :label="dict.label" :value="dict.label" />
          </el-select>
        </el-form-item>
        <el-form-item label="快递公司" prop="expressCompany">
          <!-- <el-input v-model="formVFU.expressCompany" placeholder="快递公司" /> -->
          <el-select v-model="fLive.expressCompany" placeholder="请选择快递公司" clearable filterable>
            <el-option v-for="dict in dict.type.sys_jst_sample_sf" :key="dict.label" :label="dict.label"
              :value="dict.label" />
          </el-select>
        </el-form-item>
        <el-form-item label="直播间名称" prop="liveRoomName">
          <!-- <el-input
                :disabled="to_sumbit"
                v-model="form.liveRoomName"
                placeholder="请输入直播间名称"
              /> -->
          <el-select v-model="fLive.liveRoomName" clearable placeholder="直播间名称" filterable>
            <el-option v-for="(val, key) in liveroomList" :key="key" :label="val.liveStreamRoom"
              :value="val.liveStreamRoom" />
          </el-select>
        </el-form-item>
        <el-row v-for="(noticItem, index) in colorProperty" :key="index">
          <el-col>
            <el-form-item label="合作款式" prop="colorProperty">
              <el-select v-model="noticItem.value" clearable filterable remote :remote-method="getData" :loading="loading"
                placeholder="合作款式">
                <el-option v-for="item in productNooptions" :key="item" :label="item" :value="item">
                </el-option>
              </el-select>
            </el-form-item>
            <el-button type="primary" size="mini" @click="addDomain">新增</el-button>
            <el-button type="danger" size="mini" @click.prevent="removeDomain(noticItem)">删除</el-button>
          </el-col>
        </el-row>
        <!-- </template> -->
      </el-form>
      <div slot="footer" class="dialog-footer" style="margin-top: 50px">
        <el-button type="primary" @click="submitLive('fLive')">确 定</el-button>
        <!-- <el-button @click="canNew">取 消</el-button> -->
        <!-- <el-button @click="addDomain">新增</el-button> -->
      </div>
    </el-dialog>

    <!-- 内部寄样 -->
    <el-dialog :visible.sync="VisibleVFU" append-to-body title="内部寄样" width="500px" v-if="VisibleVFU">
      <el-form ref="formVFU" :model="formVFU" :rules="rules" label-width="110px" :inline="true">
        <el-form-item label="请选择收件地址" prop="address">
          <el-select v-model="formVFU.id">
            <el-option v-for="item in optionsContact" :key="item.id"
              :label="`${item.recipient},${item.phone},${item.receiverState}${item.receiverCity}${item.receiverDistrict}${item.address}`"
              :value="item.id" />
          </el-select>
        </el-form-item>
        <el-form-item label="是否归还" prop="isReturn">
          <!-- <el-input v-model="formVFU.isReturn" placeholder="是否归还" /> -->
          <el-select v-model="formVFU.isReturn" placeholder="请选择是否归还" clearable filterable>
            <el-option v-for="dict in dict.type.sys_one_zero" :key="dict.value" :label="dict.label" :value="dict.label" />
          </el-select>
        </el-form-item>
        <el-form-item label="快递公司" prop="expressCompany">
          <!-- <el-input v-model="formVFU.expressCompany" placeholder="快递公司" /> -->
          <el-select v-model="formVFU.expressCompany" placeholder="请选择快递公司" clearable filterable>
            <el-option v-for="dict in dict.type.sys_jst_sample_sf" :key="dict.label" :label="dict.label"
              :value="dict.label" />
          </el-select>
        </el-form-item>
        <el-row v-for="(noticItem, index) in colorProperty" :key="index">
          <el-col>
            <el-form-item label="合作款式" prop="colorProperty">
              <!-- <el-input v-model="noticItem.value" placeholder="请输入颜色属性" /> -->
              <el-select v-model="noticItem.value" clearable filterable remote :remote-method="getData" :loading="loading"
                placeholder="合作款式">
                <el-option v-for="item in productNooptions" :key="item" :label="item" :value="item">
                </el-option>
              </el-select>
            </el-form-item>
            <el-button size="mini" @click.prevent="removeVFU(noticItem)">删除</el-button>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer" style="margin-top: 50px">
        <el-button type="primary" @click="submitVFU">确 定</el-button>
        <!-- <el-button @click="canNew">取 消</el-button> -->
        <el-button @click="addVFU">新增</el-button>
      </div>
    </el-dialog>

    <!-- 自行寄出 -->
    <el-dialog :visible.sync="VisibleSelf" append-to-body title="自行寄出" width="500px" v-if="VisibleSelf">
      <el-form ref="formVFU" :model="formSelf" :rules="rules" label-width="110px" :inline="true">
        <!-- <el-form-item label="是否归还" prop="isReturn">
   
    <el-select v-model="formVFU.isReturn" placeholder="请选择是否归还" clearable filterable>
      <el-option v-for="dict in dict.type.sys_one_zero" :key="dict.value" :label="dict.label" :value="dict.label" />
    </el-select>
  </el-form-item> -->
        <el-form-item label="快递公司" prop="expressCompany">
          <!-- <el-input v-model="formVFU.expressCompany" placeholder="快递公司" /> -->
          <el-select v-model="formSelf.expressCompany" placeholder="请选择快递公司" clearable filterable>
            <el-option v-for="dict in dict.type.sys_sample_sf" :key="dict.value" :label="dict.label"
              :value="dict.label" />
          </el-select>
        </el-form-item>
        <el-form-item label="退货快递单号" prop="address">
          <!-- <el-select v-model="formSelf.id">
      <el-option v-for="item in optionsContact" :key="item.id" :label="item.address" :value="item.id" />
    </el-select> -->
          <el-input v-model="formSelf.expressNumber" placeholder="请输入退货快递单号" type="number"
            oninput="value=value.replace(/^0|[^0-9]/g,'')" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer" style="margin-top: 50px">
        <el-button type="primary" @click="submitSelfReturn">确 定</el-button>
        <!-- <el-button @click="canNew">取 消</el-button> -->
        <el-button @click="cancelSelf">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog :visible.sync="Visiblereturn" append-to-body title="发起退货" width="500px" v-if="Visiblereturn">
      <el-form ref="fReturn" :model="fReturn" :rules="rules" label-width="110px" :inline="true">
        <!-- <el-form-item label="寄出方式" prop="returnAddress">
          <el-radio-group
            v-model="state"
            size="small"
            fill="#66b1ff"
            @change="changeState"
          >
            <el-radio :label="0">上门取件</el-radio>
            <el-radio :label="1">自行寄出</el-radio>
          </el-radio-group>
        </el-form-item> -->

        <el-form-item label="取件地址" prop="returnAddress" v-show="noSelf">
          <el-select v-model="fReturn.returnContactId">
            <el-option v-for="item in optionsContact" :key="item.id"
              :label="`${item.phone},${item.recipient},${item.receiverState}${item.receiverCity}${item.receiverDistrict}${item.address}`"
              :value="item.id" />
          </el-select>
        </el-form-item>
        <el-form-item label="仓库地址" prop="returnAddress" v-show="noSelf">
          <el-select @focus="onFocus" v-model="fReturn.sampleReturnAddressId" clearable filterable remote
            :remote-method="changeAddress">
            <el-option v-for="item in returnAddressList" :key="item.id"
              :label="`${item.returnName},${item.returnPhone},${item.returnAddress}`" :value="item.id" />
          </el-select>
        </el-form-item>
        <el-form-item label="预约日期" prop="pickupDayType" v-show="noSelf">
          <el-select v-model="fReturn.pickupDayType" placeholder="请选择预约时间" clearable>
            <el-option v-for="dict in dict.type.sys_sample_day" :key="dict.value" :label="dict.label"
              :value="dict.label" />
          </el-select>
        </el-form-item>

        <el-form-item label="上门时间" prop="returnDate" v-show="noSelf">
          <el-select v-model="returnDate" placeholder="请选择上门时间" clearable>
            <el-option v-for="dict in dict.type.sys_sample_time" :key="dict.value" :label="dict.label"
              :value="dict.label" />
          </el-select>
        </el-form-item>
        <el-form-item label="快递公司" prop="expressCompany">
          <!-- <el-input v-model="Contact.expressCompany" placeholder="快递公司" /> -->
          <el-select v-model="fReturn.expressCompany" placeholder="请选择快递公司" clearable filterable v-if="noSelf">
            <el-option v-for="dict in dict.type.sys_sample_sf" :key="dict.value" :label="dict.label"
              :value="dict.label" />
          </el-select>
          <el-select v-model="fReturn.expressCompany" placeholder="请选择快递公司" clearable filterable v-if="!noSelf">
            <el-option v-for="dict in dict.type.sys_jst_sample_sf" :key="dict.label" :label="dict.label"
              :value="dict.label" />
          </el-select>
        </el-form-item>
        <el-form-item label="退货快递单号" prop="address" v-show="!noSelf">
          <!-- <el-select v-model="formSelf.id">
      <el-option v-for="item in optionsContact" :key="item.id" :label="item.address" :value="item.id" />
    </el-select> -->
          <el-input v-model="fReturn.expressNumber" placeholder="请输入退货快递单号"
            oninput="value=value.replace(/[^0-9A-Za-z]/g,'')" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer" style="margin-top: 50px">
        <el-button type="primary" @click="submitReturn" v-show="noSelf">确 定</el-button>
        <el-button type="primary" @click="submitSelf" v-show="!noSelf">确 定</el-button>
        <!-- <el-button @click="canNew">取 消</el-button> -->
        <el-button @click="Return">取消</el-button>
      </div>
    </el-dialog>

    <!-- 添加或修改产品二级信息对话框 :on-change="handleChange"-->
    <el-dialog title="支付信息" :visible.sync="payopen" append-to-body>
      <el-table :data="payList">
        <!-- <el-table-column type="selection" width="55" align="center" /> -->
        <!-- <el-table-column label="支付ID" align="center" prop="id" />
      <el-table-column label="达人信息表ID" align="center" prop="sampleTalentInfoId" /> -->
        <el-table-column label="支付方式" align="center" prop="payMethod" />
        <el-table-column label="支付账号" align="center" prop="payAccount" />
        <el-table-column label="收款码" align="center" prop="payImage">
          <template #default="scope">
            <el-popover effect="light" trigger="click" placement="bottom" width="auto" v-if="scope.row.payImage">
              <template #default>
                <img :src="pjtUrl + scope.row.payImage" style="width: 800px; height: 600px; object-fit: contain" lazy />
              </template>
              <template #reference>
                <img :src="pjtUrl + scope.row.payImage" style="object-fit: contain; width: 80px; height: 80px" lazy />
              </template>
            </el-popover>
          </template>
        </el-table-column>
        <el-table-column label="姓名" align="center" prop="payName" />
        <el-table-column label="备注" align="center" prop="remark" />
      </el-table>
    </el-dialog>

    <!-- 添加或修改产品一级信息对话框 -->
    <el-dialog :visible.sync="iscontactList" width="95%" height="100%" append-to-body v-if="iscontactList">
      <Add :contactList="list" :sampleTalentCooperateType="'live'" />
    </el-dialog>
    <!-- 添加或修改产品二级信息对话框 :on-change="handleChange"-->
    <el-dialog title="联系方式" :visible.sync="contactopen" append-to-body>
      <el-row class="mb8" :gutter="10">
        <el-col :span="1.5">
          <el-button type="primary" size="mini" plain icon="el-icon-plus" @click="handeiscontactList">批量寄样</el-button>
        </el-col>
      </el-row>
      <el-table :data="contactList" @selection-change="handleContactList" height="600">
        <el-table-column type="selection" width="55" align="center" />
        <!-- <el-table-column label="联系ID" align="center" prop="id" />
      <el-table-column label="达人信息表ID" align="center" prop="sampleTalentInfoId" /> -->
        <el-table-column label="收件人" align="center" prop="recipient" />
        <el-table-column label="电话" align="center" prop="phone" />

        <el-table-column label="收货省份" align="center" prop="receiverState" />
        <el-table-column label="收货市" align="center" prop="receiverCity" />
        <el-table-column label="收货区" align="center" prop="receiverDistrict" />
        <!-- <el-table-column label="收件人地址" align="center" prop="address" /> -->
        <el-table-column label="收件人地址" align="center" prop="address" />
        <!-- :formatter="formatData" -->
        <el-table-column label="备注" align="center" prop="remark" />
      </el-table>
    </el-dialog>

    <!-- 添加或修改产品二级信息对话框 :on-change="handleChange"-->
    <el-dialog title="联系方式" :visible.sync="openApply" append-to-body width="80%">
      <el-table :data="sampleApplyList">
        <!-- <el-table-column type="selection" width="55" align="center" /> -->
        <!-- <el-table-column label="联系ID" align="center" prop="id" />
      <el-table-column label="达人信息表ID" align="center" prop="sampleTalentInfoId" /> -->
        <!-- <el-table-column label="电话" align="center" prop="phone" />
        <el-table-column label="收件人" align="center" prop="recipient" />
        <el-table-column label="收件人地址" align="center" prop="address" />
        <el-table-column label="备注" align="center" prop="remark" /> -->
        <el-table-column label="合作款式" align="center" prop="productNo" width="110" />
        <el-table-column label="款式主图" align="center" prop="styleMainImage">
          <template slot-scope="scope">
            <image-preview :src="scope.row.styleMainImage" :width="50" :height="50" />
          </template>
        </el-table-column>
        <el-table-column label="商品编码" align="center" prop="productCode" />
        <el-table-column label="商品数量" align="center" prop="productNum" />
        <el-table-column label="颜色属性" align="center" prop="colorProperty" />
        <el-table-column label="尺寸" align="center" prop="size" />
        <el-table-column label="申请人" align="center" prop="buyerAccount" />
        <el-table-column label="申请时间" align="center" prop="createTime" />
        <el-table-column label="手机" align="center" prop="phone" width="110" />
        <el-table-column label="收件人" align="center" prop="recipient" />
        <el-table-column label="收件人地址" align="center" prop="address">
          <template slot-scope="scope">
            <el-popover trigger="hover" placement="top" width="300">
              <!-- <span>{{ scope.row.customerProductTalking }}</span> -->
              <el-input v-model="scope.row.address" :min-height="192" type="textarea"
                :autosize="{ minRows: 2, maxRows: 24 }" :style="{ width: '100%' }" :disabled="true" />
              <div slot="reference">
                <span class="textname">{{ scope.row.address }} </span>
              </div>
            </el-popover>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>

<script>
import axios from "axios";
import {
  listReturnAddress,
  getReturnAddress,
  delReturnAddress,
  addReturnAddress,
  updateReturnAddress,
  search,
} from "@/api/sample/returnAddress";
import { province } from "@/api/sample/map";
import {
  listSecondry,
  getSecondry,
  delSecondry,
  addSecondry,
  updateSecondry,
  getInfoByName,
  productNoColorLike,
  listAll,
} from "@/api/product/secondry";
import {
  listSampleApply,
  getSampleApply,
  delSampleApply,
  addSampleApply,
  updateSampleApply,
  addApply,
  returnApply,
  selectuserList,
} from "@/api/sample/sampleApply";
import {
  listContact,
  getContact,
  delContact,
  addContact,
  updateContact,
} from "@/api/sample/contact";
import { listPay, getPay, delPay, addPay, updatePay } from "@/api/sample/pay";
import { batchAdd } from "@/api/sample/live";
import {
  listNote,
  getNote,
  delNote,
  addNote,
  updateNote,
} from "@/api/sample/note";
import {
  listTemplate,
  getTemplate,
  delTemplate,
  addTemplate,
  updateTemplate,
  addTemplateAndSecondry,
  addProNoColorSize,
  productNoLike,
} from "@/api/product/template";
import {
  selectTalentInfoList,
  listSample,
  getSample,
  delSample,
  addSample,
  updateSample,
  SampleTalentFirstAdd,
  selectTalentNameList,
  batchDistributionTalent
} from "@/api/sample/sample";
import {
  listLiveroom,
  getLiveroom,
  delLiveroom,
  addLiveroom,
  updateLiveroom,
} from "@/api/sample/liveroom";
import Add from "@/views/sample/Add/Add.vue";
import { downLoadTemplate } from "@/api/data/template";
//--------导入token
import { getToken } from "@/utils/auth";
import Detail from "./Detail"; // 新建页面
import dialogApply from "@/views/sample/bootcommon/sampleApply"; // 新建页面
import BiTalentContacts from "@/views/talent/BiTalentContacts/index.vue";
import {
  listBiTalentContacts,
  getBiTalentContacts,
  delBiTalentContacts,
  addBiTalentContacts,
  updateBiTalentContacts,
} from "@/api/talent/BiTalentContacts";
import {
  releaseTalent,
  distributionTalent,
  setLabel,
  talentBlock,
  selectTalentLabel,
  buildRelationship,
} from "@/api/talent/Detail";
export default {
  name: "Sample",
  dicts: [
    "sys_product_qudao",
    "sys_sample_status",
    "sys_sample_sf",
    "sys_one_zero",
    "sys_sample_day",
    "sys_sample_time",
    "sys_sample_name",
    "sys_sample_cj",
    "sys_jst_sample_sf",
  ],
  components: {
    Add,
    Detail,
    dialogApply,
    BiTalentContacts,
  },
  props: {
    activePlatform: {
      type: String,
      default: null,
    },
  },
  data() {
    return {
      isFollowList: ['是', '否'],

      inputVisible: false,
      inputValue: "",
      TalentLabelList: [],
      formLabel: {},
      openLabel: false,
      dynamicTags: [],

      BiTalentContactsList: [],
      openBiTalentContacts: false,

      userList: [],
      openUpload: false,
      openOrderNumber: false,
      formApply: {},

      xhsNicknameList: [],
      openInfo: false,
      row: {},
      showDetail: false,
      liveroomList: [],
      //一键寄样
      iscontactList: false,
      list: [],
      page: {
        pageNum: 1,
        pageSize: 100,
      },
      pjtUrl: process.env.VUE_APP_BASE_API,
      //上门时间
      returnDate: "15:00-17:00",
      //上门取件or自行寄出
      state: 1,
      noSelf: false,

      VisibleSelf: false,
      formSelf: {
        expressCompany: "中通快递",
      },

      //模糊匹配
      sizeList: [],
      ColorLike: [],
      options: [], // 选项，从后端传递过来

      openAll: false,
      //省市区
      arr: [1, 3, 4],
      province: [],
      cityarr: [],
      regionarr: [],

      tableHeight: "",
      //达人收件信息
      optionsContact: [],
      formVFU: {
        isReturn: "是",

        expressCompany: "中通快递",
      },
      VisibleVFU: false,
      fVFU: {
        colorProperty: [{ value: "" }],
      },
      //上门取件
      Visiblereturn: false,
      fReturn: {
        pickupDayType: "今天",
        expressCompany: "中通快递",
      },
      returnAddressList: [],

      openApply: false,
      sampleApplyList: [],

      contactopen: false,
      contactList: [],
      //  达人信息-支付信息表格数据
      payList: [],
      payopen: false,
      productNooptions: [],
      // 表单参数
      fAdd: {
        colorProperty: [{ value: "" }],
      },
      //笔记合作方式

      Visiblenote: false,
      // 表单参数
      fLive: {
        id: "",
        isReturn: "是",
        liveRoomName: "非直播间申请",
        expressCompany: "中通快递",
      },
      colorProperty: [{ value: "" }],
      //笔记合作方式

      VisibleLive: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 达人信息表格数据
      sampleList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        platform: null,
        talentLevel: null,
        platformId: null,
        xhsNickname: null,
        contactPerson: null,
        recommendSituation: null,
        reason: null,
        personnelType: null,
        homeLink: null,
        fansNum: null,
        likeNum: null,
        cooperatePrice: null,
        contactWechat: null,
        talentStatus: null,
        isDelete: null,
        fansNumStart: null,
        fansNumEnd: null,
        likeNumStart: null,
        likeNumEnd: null,
      },
      // 表单参数
      form: {
        // isReturn: '是'
      },
      // 表单校验
      rules: {
        platform: [
          { required: true, message: "平台名称不能为空", trigger: "blur" },
        ],
        platformId: [
          { required: true, message: "平台ID不能为空", trigger: "blur" },
        ],
      },
    };
  },
  watch: {
    activePlatform: {
      handler: function (newnew, oldold) {
        this.queryParams.platform = this.activePlatform;
        this.getList();
      },
      deep: true,
      immediate: true,
    },
  },
  created() {
    selectuserList().then((response) => {
      this.userList = response
    });
    selectTalentNameList().then((response) => {
      this.xhsNicknameList = response;
    });
    listLiveroom({
      pageNum: 1,
      pageSize: 100,
    }).then((response) => {
      response.rows.unshift({ liveStreamRoom: "非直播间申请" });
      this.liveroomList = response.rows;
      // this.total = response.total;
      // this.loading = false;
    });
    // this.$set(this.fLive, "colorProperty", null);
    this.provincearr = province;
    // this.getList();
    // if (this.$route.query.platformId) {
    //   this.$set(this.queryParams, "platformId", this.$route.query.platformId);
    // }
    // this.getList();
  },
  mounted() {
    var _this = this;
    this.resizeTable();
    window.onresize = function () {
      _this.resizeTable();
    };
  },
  //记得清空  如果在keepalive中 则使用activated  deactivated
  destroyed() {
    // Object.assign(this.$data, this.$options.data());
    window.onresize = null;
  },
  methods: {
    //标签
    selectTalentLabelByid() {
      selectTalentLabel({ talentId: this.row.platformId }).then((response) => {
        this.formLabel.talentLabel = response;
        this.dynamicTags = response;
      });
    },
    handleselectLabel(dict) {

      if (this.dynamicTags.includes(dict)) {
        this.$modal.msgError("该标签已存在");
        return;
      }
      this.dynamicTags.push(dict);
    },
    handleopenLabel() {
      // if (this.list.length != 1) {
      //   this.$modal.msgError("请选择一个达人");
      //   return;
      // }
      selectTalentLabel().then((response) => {
        this.TalentLabelList = response;
      });
      this.row = this.form
      this.selectTalentLabelByid();
      this.openLabel = true;
    },

    //标签
    handlesetLabel() {
      let talentLabel = this.dynamicTags.join(",");
      let obj = {
        query: { talentLabel: talentLabel, id: this.row.id },
        // data: this.row,
      };
      setLabel(obj).then((response) => {
        if (response.code == 200) {
          this.$modal.msgSuccess("已分配标签");
          this.openLabel = false;
          this.getList()
          this.count++;
        }
      });
    },
    handleClose(tag) {
      this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1);
    },
    showInput() {
      this.inputVisible = true;
      this.$nextTick((_) => {
        this.$refs.saveTagInput.$refs.input.focus();
      });
    },

    handleInputConfirm() {
      let inputValue = this.inputValue;
      if (this.dynamicTags.includes(inputValue)) {
        this.$modal.msgError("该标签已存在");
        return;
      }
      if (inputValue) {
        this.dynamicTags.push(inputValue);
      }
      this.inputVisible = false;
      this.inputValue = "";
    },


    handleBiTalentContacts() {
      if (!this.form.platformId) {
        this.$modal.msgError("请输入平台id")
        return
      }
      this.openBiTalentContacts = true
    },
    downLoadTemplateFile() {
      let obj = {
        templateName: "达人信息批量导入",
      };
      downLoadTemplate(obj).then((response) => {
        window.location.href =
          process.env.VUE_APP_BASE_API + response.rows[0].templateUrl;
      });
    },
    handleformApply() {
      if (this.ids.length < 1) {
        this.$modal.msgError('请选择一条数据')
        return
      }
      this.openOrderNumber = true
    },
    handlebatchDistributionTalent() {
      if (!this.formApply.contactPerson) {
        this.$modal.msgError('请输入分配的达人')
        return
      }
      let obj = {
        ids: this.ids.toString(),

        contactPerson: this.formApply.contactPerson
      }
      batchDistributionTalent(obj).then(response => {
        if (response.code == 200) {
          this.$modal.msgSuccess(response.msg)
          this.openOrderNumber = false
          this.getList()
        }
      })
    },
    gotoApply(row) {
      this.row = row;
      this.openInfo = true;
      // this.$router.push({ path: "/sample/sampleApply", query: { id: row.id } });
    },
    tableRowClassName({ row, column, rowIndex, columnIndex }) {
      return "color: #515a6e;background:#c4dbf0 !important;";
    },
    handleNickname(row) {
      this.row = row;
      this.showDetail = true;
    },
    handleClose() {
      this.getList();
      this.showDetail = false;
      // this.isShowSecond = false;
    },
    addText() {
      if (!this.form.homeLink) {
        this.$modal.msgError("请输入内容");
        return;
      }
      const parts = this.form.homeLink.split("/");

      // 找到包含用户ID的部分（它应该是'/user/profile/'之后的第一个部分）
      // 注意：数组索引是从0开始的，所以'-2'实际上是指向倒数第二个'/'之后的部分
      const userIdPart = parts[parts.length - 1];
      let obj = {
        noteid: userIdPart,
      };
      // let fd = new FormData();
      // fd.append("noteid", userIdPart);
      axios
        .post(
          "http://47.107.129.160:5000/api/get_user_info",
          JSON.stringify(obj)
          // {
          // headers: {
          //   // header: { responseType: "blob" },

          //   // Authorization: "Bearer " + getToken(),
          //   "Content-Type": "application/json",
          // }, //定义内容格式,很重要
          // // timeout: 20000,
          // }
        )
        .then((response) => { });
      // axios
      //   .post({
      //     // method: "POST",
      //     url: "http://47.107.129.160:5000/api/get_user_info",
      //     // url: "http://47.97.123.182:1399/smAddress",
      //     data: JSON.stringify(obj),
      //     headers: {
      //       // header: { responseType: "blob" },

      //       // Authorization: "Bearer " + getToken(),
      //       "Content-Type": "application/json",
      //     },
      //     // "Content-Type": "application/json",
      //     //         headers:
      //     // Content-Type':'application/json'，//告诉服务器发送的是JSON数据

      //     // headers: {
      //     //   // header: { responseType: "blob" },

      //     //   // Authorization: "Bearer " + getToken(),
      //     //   "Content-Type": "application/json",
      //     // }, //定义内容格式,很重要
      //     // // timeout: 20000,
      //   })
      //   .then((response) => {});
    },
    submitFormAll() { },
    cancelAll() {
      this.openAll = false;
    },

    handleAddAll() {
      this.openAll = true;
    },

    //修改对话框
    //添加颜色列表获得焦点
    onFocus() {
      this.getData();

      this.getSize();
      this.changeAddress("");
      // if (!this.form.colorProperty) {
      //     this.$selectRef.value.blur() //就是这一句，
      // }
    },

    //修改对话框
    /* 获取颜色列表 */
    getSize(key) {
      console.log(JSON.stringify(key));
      // this.loading = true;
      // return
      listAll({
        productNo: this.form.productNo,
        colorProperty: this.form.colorProperty,
      }).then((res) => {
        // this.loading = false;
        this.sizeList = res;
        console.log(JSON.stringify(res));
      });
    },
    /* 获取颜色列表 */
    getData(key) {
      console.log(JSON.stringify(key));
      // this.loading = true;
      // return
      productNoColorLike({ productNo: this.form.productNo, color: key }).then(
        (res) => {
          // this.loading = false;
          this.ColorLike = res.data;
          console.log(JSON.stringify(this.ColorLike));
        }
      );
    },

    /* 获取货号列表 */
    getDatas(key) {
      console.log(JSON.stringify(key));
      this.loading = true;
      // return
      productNoLike(key).then((res) => {
        this.loading = false;
        this.options = res.data;
        console.log(JSON.stringify(this.options));
      });
    },
    //自行寄出
    chatReturnSelf() {
      if (this.ids.length > 1 || this.ids.length == 0) {
        this.$modal.msgError("请选择一个指定达人信息！");
        return;
      }

      this.VisibleSelf = true;
    },
    cancelSelf() {
      this.VisibleSelf = false;
    },
    submitSelfReturn() {
      if (!this.formSelf.expressNumber) {
        this.$modal.msgError("请输入退货快递单号");
        return;
      }
      var formreturn = {
        returnMethod: "selfsending",
        sampleTalentInfoId: this.ids[0],
        ...this.formSelf,
      };
      console.log(JSON.stringify(formreturn));
      // return
      returnApply(formreturn).then((response) => {
        this.VisibleSelf = false;
        if (response.code == 200) {
          if (response.msg == "操作完成！") {
            this.$modal.msgSuccess("申请成功");
            this.$router.push({
              path: "/sample/returned/sampleReturn",
              query: { sampleTalentInfoId: this.ids[0] },
            });
          } else {
            this.$modal.msgError(response.msg);
          }
        } else {
          this.$modal.msgError(response.msg);
        }
      });
    },
    submitSelf() {
      if (!this.fReturn.expressNumber) {
        this.$modal.msgError("请输入退货快递单号");
        return;
      }
      var formreturn = {
        returnMethod: "selfsending",
        sampleTalentInfoId: this.ids[0],
        ...this.fReturn,
      };
      console.log(JSON.stringify(formreturn));
      // return
      // returnApply(formreturn)
      axios
        .post(
          process.env.VUE_APP_BASE_API + "/product/sampleApply/returnApply",
          formreturn,
          {
            headers: {
              header: {
                // responseType: "blob"
              },

              Authorization: "Bearer " + getToken(),
              // "Content-Type": "multipart/form-data",
            }, //定义内容格式,很重要
            // timeout: 20000,
          }
        )
        .then((response) => {
          this.Visiblereturn = false;
          if (response.data.code == 200) {
            if (response.data.msg == "操作完成！") {
              this.$modal.msgSuccess("申请成功");
              this.$router.push({
                path: "/sample/returned/sampleReturn",
                query: { sampleTalentInfoId: this.ids[0] },
              });
            } else {
              this.$modal.msgError(response.data.msg);
            }
          } else if (response.data.code == 500) {
            this.$alert(response.data.msg, "提示", {
              confirmButtonText: "前往认领",
            }).then(() => {
              this.$router.push({
                path: "/sample/returned/AfterSalesOrder",
                query: { trackingNumber: this.fReturn.expressNumber },
              });
            });
            // this.$alert(
            //   "快递单号已存在，请在聚水潭售后单查询该快递单号!",
            //   "提示",
            //   {
            //     confirmButtonText: "确定",
            //   }
            // ).then(() => {
            //   this.$router.push({
            //     path: "/sample/AfterSalesOrder",
            //     query: { trackingNumber: this.fReturn.expressNumber },
            //   });
            // });
          }
          // else {
          //   this.$modal.msgError(response.msg);
          // }
        });
    },
    changeAddress(val) {
      console.log(val);
      search(val).then((response) => {
        console.log(JSON.stringify(response));
        this.returnAddressList = response;
      });
    },
    changeState(val) {
      console.log(val);
      if (val == 0) {
        console.log(0);
        this.fReturn = {};
        // this.fReturn.expressCompany = '中通快递'
        this.noSelf = true;
      } else {
        console.log(1);
        this.fReturn = {};
        // this.fReturn.expressCompany = '中通快递'
        this.noSelf = false;
      }
    },

    //申请退货
    chatReturn(row) {
      if (this.ids.length > 1 || this.ids.length == 0) {
        this.$modal.msgError("请选择一个指定达人信息！");
        return;
      }

      listContact({ sampleTalentInfoId: this.ids[0], ...this.page }).then(
        (res) => {
          if (res.rows.length == 0) {
            this.$modal.msgError("请添加达人收件信息！");
            return;
          } else if (res.rows.length > 0) {
            this.optionsContact = res.rows;
            console.log(JSON.stringify(this.optionsContact));
            this.Visiblereturn = true;
          }
        }
      );
    },
    Return() {
      this.Visiblereturn = false;
    },
    submitReturn() {
      if (!this.fReturn.returnContactId) {
        this.$modal.msgError("请选择取件地址");
        return;
      }
      if (!this.fReturn.sampleReturnAddressId) {
        this.$modal.msgError("请选择仓库地址");
        return;
      }
      var pickupStartTime = this.returnDate.split("-")[0];
      var pickupEndTime = this.returnDate.split("-")[1];
      console.log(JSON.stringify(pickupStartTime));
      console.log(JSON.stringify(pickupEndTime));
      var formreturn = {
        returnMethod: "pickup",
        sampleTalentInfoId: this.ids[0],
        ...this.fReturn,
        pickupStartTime: pickupStartTime,
        pickupEndTime: pickupEndTime,
      };
      console.log(JSON.stringify(formreturn));
      // return
      returnApply(formreturn).then((response) => {
        this.Visiblereturn = false;
        if (response.code == 200) {
          if (response.msg == "操作完成！") {
            this.$modal.msgSuccess("申请成功");
            this.$router.push({
              path: "/sample/returned/sampleReturn",
              query: { sampleTalentInfoId: this.ids[0] },
            });
          } else {
            this.$modal.msgError(response.msg);
          }
        } else {
          this.$modal.msgError(response.msg);
        }
      });
    },
    //点击某一行
    t(row, column, cell, event) {
      console.log(row, column, cell, event);
      this.handleUpdate(row);
    },

    /* 获取货号列表 */
    getData(key) {
      console.log(JSON.stringify(key));
      this.loading = true;
      // return
      productNoLike(key).then((res) => {
        this.loading = false;
        this.productNooptions = res.data;
        // console.log(JSON.stringify(this.options));
      });
    },

    // 删除
    removeVFU(item) {
      var index = this.colorProperty.indexOf(item);
      if (index == "0") {
        // 还有一个的时候提示不能删除
        this.$message({
          message: "不能删除了",
          type: "error",
        });
        return false;
      }
      if (index !== -1 && index !== "0") {
        this.colorProperty.splice(index, 1);
      }
    },
    // 表单新增
    addVFU() {
      this.colorProperty.push({
        value: "",
        // key: Date.now()+,
      });
    },

    //批量添加
    chatVFU(row) {
      if (this.ids.length > 1 || this.ids.length == 0) {
        this.$modal.msgError("请选择一个指定达人信息！");
        return;
      }
      listContact({ sampleTalentInfoId: this.ids[0], ...this.page }).then(
        (res) => {
          if (res.rows.length == 0) {
            this.$modal.msgError("请添加达人收件信息！");
            return;
          } else if (res.rows.length > 0) {
            this.optionsContact = res.rows;
            console.log(JSON.stringify(this.optionsContact));
            this.VisibleVFU = true;
          }
        }
      );
    },
    //批量添加
    submitVFU() {
      if (!this.formVFU.id) {
        this.$modal.msgError("请选择一个收件地址！");
        return;
      }
      // this.fLive.sampleTalentInfoId = this.ids[0]
      let label = [];
      this.colorProperty.forEach((item) => {
        //判断条件 货号不能为空
        if (label.indexOf(item.value) == -1 && item.value !== "") {
          label.push({
            productNo: item.value,
            sampleTalentInfoId: this.ids[0],
            sampleTalentCooperateId: null,
            sampleTalentCooperateType: "VFU",
            contactId: this.formVFU.id,
            ...this.formVFU,
          });
        }
      });
      if (label.length == 0) {
        this.$modal.msgError("请选择至少一个合作款式！");
        return;
      }
      this.formVFU = label;
      // console.log(JSON.stringify(this.fLive.sampleTalentTemplateList));
      console.log(JSON.stringify(this.formVFU));
      // return
      this.$refs["formVFU"].validate((valid) => {
        if (valid) {
          addApply(this.formVFU).then((response) => {
            if (response.code == 200) {
              this.$modal.msgSuccess("申请成功");

              // this.getList();
              // this.fAdd.colorProperty = []
              this.VisibleVFU = false;
              this.colorProperty = this.$options.data().colorProperty;
              this.$router.push({
                path: "/sample/sampleApply",
                query: { id: this.ids[0] },
              });
              // Object.assign(this.$data, this.$options.data());
            } else {
              this.$modal.msgError("新增失败！");
              Object.assign(this.$data, this.$options.data());
              this.VisibleVFU = false;
              this.getList();
            }
          });
        }
      });
    },

    // 删除
    removeLive(item) {
      var index = this.colorProperty.indexOf(item);
      if (index == "0") {
        // 还有一个的时候提示不能删除
        this.$message({
          message: "不能删除了",
          type: "error",
        });
        return false;
      }
      if (index !== -1 && index !== "0") {
        this.colorProperty.splice(index, 1);
      }
    },
    // 表单新增
    addLive() {
      this.colorProperty.push({
        value: "",
        key: Date.now(),
      });
    },
    //批量添加
    chatlive(row) {
      if (this.ids.length > 1 || this.ids.length == 0) {
        this.$modal.msgError("请选择一个指定达人信息！");
        return;
      }
      listContact({ sampleTalentInfoId: this.ids[0], ...this.page }).then(
        (res) => {
          if (res.rows.length == 0) {
            this.$modal.msgError("请添加达人收件信息！");
            return;
          } else if (res.rows.length > 0) {
            this.optionsContact = res.rows;
            console.log(JSON.stringify(this.optionsContact));

            this.VisibleLive = true;
            this.fLive.id = "";
            // this.$refs.fLiveRef.toggleDropDownVisible(true);
            // this.$refs.fLiveRef.toggleMenu();
          }
        }
      );
    },
    //批量添加
    submitLive(formName) {
      if (!this.fLive.id) {
        this.$modal.msgError("请选择一个收件地址！");
        return;
      }
      // this.fLive.sampleTalentInfoId = this.ids[0]
      let label = [];
      // this.fLive.colorProperty.forEach((item) => {
      this.colorProperty.forEach((item) => {
        //判断条件 货号不能为空
        if (label.indexOf(item.value) == -1 && item.value !== "") {
          label.push({
            productNo: item.value,
            sampleTalentInfoId: this.ids[0],
            sampleTalentCooperateId: null,
            sampleTalentCooperateType: "live",
            contactId: this.fLive.id,
            isReturn: this.fLive.isReturn,
            expressCompany: this.fLive.expressCompany,
            liveRoomName: this.fLive.liveRoomName,
            // ...this.fLive
          });
        }
      });
      if (label.length == 0) {
        this.$modal.msgError("请选择至少一个合作款式！");
        return;
      }
      this.fLive = label;
      // .filter((num, index) => { return num !== 'colorProperty' })
      // for (var item in this.fLive) {
      //   if (item == 'colorProperty') {
      //     delete this.fLive[item];
      //   }
      // }
      // console.log(JSON.stringify(this.fLive.sampleTalentTemplateList));
      console.log(JSON.stringify(this.fLive));
      // return
      this.$refs["fLive"].validate((valid) => {
        if (valid) {
          addApply(this.fLive).then((response) => {
            this.$refs["fLive"].resetFields();
            if (response.code == 200) {
              this.$modal.msgSuccess("新增成功");
              //
              // this.getList();
              // this.fAdd.colorProperty = []
              // this.$set(this.fLive, {});
              this.VisibleLive = false;
              this.colorProperty = this.$options.data().colorProperty;
              // Object.assign(, );
              this.$router.push({
                path: "/sample/sampleApply",
                query: { id: this.ids[0] },
              });
            } else {
              this.$modal.msgError("新增失败！");
              // Object.assign(this.$data, this.$options.data());
              this.VisibleLive = false;
              this.getList();
            }
          });
        }
      });
    },

    // 删除
    removeDomain(item) {
      var index = this.colorProperty.indexOf(item);
      if (index == "0") {
        // 还有一个的时候提示不能删除
        this.$message({
          message: "不能删除了",
          type: "error",
        });
        return false;
      }
      if (index !== -1 && index !== "0") {
        this.colorProperty.splice(index, 1);
      }
    },
    // 表单新增
    addDomain() {
      this.colorProperty.push({
        value: "",
        // key: Date.now()+,
      });
    },
    //批量添加
    chatAdd(row) {
      if (this.ids.length > 1 || this.ids.length == 0) {
        this.$modal.msgError("请选择一个指定达人信息！");
        return;
      }

      this.Visiblenote = true;
    },
    //批量添加
    submitNote() {
      this.fAdd.sampleTalentInfoId = this.ids[0];
      let label = [];
      this.colorProperty.forEach((item) => {
        //判断条件 货号不能为空
        if (label.indexOf(item.value) == -1 && item.value !== "") {
          label.push({ productNo: item.value });
        }
      });
      if (label.length == 0) {
        this.$modal.msgError("请选择至少一个合作款式！");
        return;
      }
      this.fAdd.sampleTalentTemplateList = label;
      console.log(JSON.stringify(this.fAdd.sampleTalentTemplateList));

      this.$refs["fAdd"].validate((valid) => {
        if (valid) {
          addNote(this.fAdd).then((response) => {
            if (response.code == 200) {
              this.$modal.msgSuccess("新增成功");
              // Object.assign(this.$data, this.$options.data());
              // this.getList();
              // this.fAdd.colorProperty = []
              this.Visiblenote = false;
              this.colorProperty = this.$options.data().colorProperty;
              this.$router.push({ path: "/sample/info/note" });
            } else {
              this.$modal.msgError("新增失败！");
              Object.assign(this.$data, this.$options.data());
              this.Visiblenote = false;
              this.getList();
            }
          });
        }
      });
    },
    /**二级配置跳转**/
    go(row) {
      this.$router.push({ path: "/sample/contact", query: { id: row.id } });
    },
    contact(row) {
      listContact({ sampleTalentInfoId: row.id, ...this.page }).then(
        (response) => {
          this.contactList = response.rows;
          this.contactopen = true;
        }
      );
    },
    formatData(row) {
      console.log(JSON.stringify(row));
      // let rowPerson = (row) || [];
      // let arr = [];
      // rowPerson.forEach(item => {
      //   //如果数据特别多的话,还可以在这里加if判断,仅展示规定的数据
      //   arr.push(item.size);
      // });
      //
      return (
        row.receiverState +
        row.receiverCity +
        row.receiverDistrict +
        row.address
      );
    },
    goto(row) {
      this.$router.push({ path: "/sample/pay", query: { id: row.id } });
    },

    pay(row) {
      listPay({ sampleTalentInfoId: row.id }).then((response) => {
        this.payList = response.rows;
        this.payopen = true;
      });
    },
    getApplyList(row) {
      listSampleApply({ sampleTalentInfoId: row.id }).then((response) => {
        this.sampleApplyList = response.rows;
        this.openApply = true;
      });
    },
    /** 查询达人信息列表 */
    getList() {
      this.loading = true;
      selectTalentInfoList(this.queryParams).then((response) => {
        this.sampleList = response.rows;
        console.log(JSON.stringify(this.sampleList));
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        platform: null,
        talentLevel: null,
        platformId: null,
        xhsNickname: null,
        contactPerson: null,
        recommendSituation: null,
        reason: null,
        personnelType: null,
        homeLink: null,
        fansNum: null,
        likeNum: null,
        cooperatePrice: null,
        contactWechat: null,
        talentStatus: null,
        isDelete: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    //一键寄样
    handeiscontactList() {
      if (this.list.length == 0) {
        this.$modal.msgError("请选择一个收件地址！");
        return;
      }
      this.iscontactList = true;
    },
    //
    handleContactList(selection) {
      this.list = [];
      this.list = selection.map((item) => item);
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加达人信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getSample(id).then((response) => {
        this.form = response.data;
        this.getBiTalentContacts()
        this.open = true;
        this.title = "修改达人信息";
      });
    },
    getBiTalentContacts() {
      listBiTalentContacts({
        pageNum: 1,
        pageSize: 10, talentId: this.form.platformId
      }).then((response) => {
        this.BiTalentContactsList = response.rows;
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.form.platform = this.activePlatform;
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updateSample(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addSample(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除达人信息编号为"' + ids + '"的数据项？')
        .then(function () {
          return delSample(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => { });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "product/sample/export",
        {
          ...this.queryParams,
        },
        `sample_${new Date().getTime()}.xlsx`
      );
    },
    // table自动高度
    returnTableHeight(ref, bottomOffset) {
      let height = null;
      height =
        window.innerHeight - ref.getBoundingClientRect().top - bottomOffset;
      return height;
    },

    resizeTable() {
      this.$nextTick(() => {
        this.tableHeight = this.returnTableHeight(this.$refs.tableDom, 100);
      }, 0);
    },

    selectProvimce(id) {
      this.cityarr = [];
      this.regionarr = [];
      this.cityValue = "";
      this.RegionValue = "";
      for (let item of this.provincearr) {
        if (id == item.name) {
          console.log(item);
          this.cityarr = item.children;
        }
      }
    },
    selectcity(id) {
      this.regionarr = [];
      this.RegionValue = "";
      for (let item of this.cityarr) {
        if (id == item.name) {
          this.regionarr = item.children;
        }
      }
    },
  },
};
</script>
<style lang="scss" scoped>
.el-dialog-div {
  overflow-x: hidden;
  height: 60vh;
}

span.textname {
  display: -webkit-box;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: pre-wrap;

  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.el-textarea.is-disabled ::v-deep .el-textarea__inner {
  width: 500px;
  color: #606266;
  background-color: white;
  border: none;
  cursor: pointer;
  resize: none;
}
</style>
